<template>
	<view class="container">
		<view class="list-cell b-b m-t" @click="navTo('./userInfo')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">个人资料</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b" @click="navTo('/pageA/setList/setList')" hover-class="cell-hover"
			:hover-stay-time="50">
			<text class="cell-tit">账号与安全</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<!-- #ifdef APP-PLUS -->
		<view class="list-cell  b-b " @click="navTo('../makemode/makemode')" hover-class="cell-hover"
			:hover-stay-time="50">
			<text class="cell-tit">鲲鱬云</text>
			<text class="cell-tip" style="color: #5990FF;">{{version}}</text>
		</view>
		<!-- #endif -->
		<view class="list-cell  b-b" @click="navTo('/pageB/noticeList/noticeInfo?name=隐私政策&type=15')"
			hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">隐私政策</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell  b-b" @click="navTo('/pageB/noticeList/noticeInfo?name=用户政策&type=16')"
			hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">用户政策</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell   b-b " @click="navTo('cancellation')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">注销账号</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell   b-b " @click="navTo('./changeUser')" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">切换账号</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="bq">
			<view>Copyright©2022-2032</view>
			<view>鲲鱬云{{baseUrl}}版权所有</view>
		</view>
		<view class="quit-login" @click="toLogout">
			<text>退出登录</text>
		</view>
	</view>
</template>

<script>
	import env from "@/util/env.js";
	import {
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				userInfo: {},
				version: '',
				baseUrl: env.prod.baseUrl
			};
		},
		onShow() {
			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, async (inf) => {
				this.version = 'V' + inf.version
				console.log('当前版本', inf.version);
			})
			// #endif
			this.getInfo()
		},
		methods: {
			...mapMutations(['logout']),
			account_change() {
				uni.navigateTo({
					url: '/pages/changeAccount/changeAccount'
				})
			},
			navTo(url) {
				if (url == 'cancellation') {
					uni.showModal({
						content: '注销账号后,账户相关信息将不可试用是否注销',
						success: (e) => {
							if (e.confirm) {
								this.$fun.msg('注销成功')
								uni.clearStorage()
								setTimeout(() => {
									uni.reLaunch({
										url: '/pageA/public/login'
									})
								}, 200)
							}
						}
					});
					return
				}
				if (url == 'wx') {
					location.href = this.$wxLogin
				}
				uni.navigateTo({
					url
				})
			},
			//重新获取用户信息
			getInfo() {
				this.$fun.ajax.post('user/index', {}).then(res => {
					this.userInfo = res.data
					this.balance = res.data.balance
				})
			},
			//退出登录
			toLogout() {
				uni.showModal({
					content: '确定要退出登录么',
					success: (e) => {
						if (e.confirm) {
							this.$fun.msg('退出成功')
							uni.clearStorage()
							setTimeout(() => {
								uni.reLaunch({
									url: '/pageA/public/login'
								})
							}, 200)
						}
					}
				});
			},
			//switch
			switchChange(e) {
				let statusTip = e.detail.value ? '打开' : '关闭';
				this.$api.msg(`${statusTip}消息推送`);
			},

		}
	}
</script>

<style lang='scss'>
	.account_change {
		width: 100%;
		text-align: center;
		position: absolute;
		bottom: 50rpx;
		left: 0;
		right: 0;
		margin: auto;
		color: rgb(0, 122, 255);
	}

	page {
		background: #f5f5f5;
		;
	}

	.list-cell {
		display: flex;
		align-items: baseline;
		padding: 20upx 32upx;
		line-height: 60upx;
		position: relative;
		background: #fff;
		justify-content: center;

		&.log-out-btn {
			margin-top: 40upx;

			.cell-tit {
				color: #333333;
				text-align: center;
				margin-right: 0;
				font-size: 20rpx;
			}
		}

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		&.m-t {
			margin-top: 16upx;
		}

		.cell-more {
			align-self: baseline;
			font-size: 26upx;
			color: #909399;
			margin-left: 10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 30rpx;
			color: #333333;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 30rpx;
			color: #333333;
			margin-right: 10upx;
		}

		switch {
			transform: translateX(16upx) scale(.84);
		}
	}

	.bq {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 130rpx;
		margin: auto;

		view {
			text-align: center;
		}
	}

	/* 退出登录 */
	.quit-login {
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 20rpx;

		text {
			color: #222222;
			font-size: 28rpx;
		}
	}
</style>